package cn.imu.appdevexperiment2020._1activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.BindView;
import butterknife.OnClick;
import cn.imu.appdevexperiment2020.R;
import cn.imu.appdevexperiment2020.common.BaseActivity;

/**
 * 描述:
 *
 * @author chenconghua
 * @version 1.0
 * @create 2022-10-26 20:21
 */
public class FirstActivity extends BaseActivity {
   @BindView(R.id.tv_fa_1)
   TextView tvFa1;
   @BindView(R.id.edt_fa_1)
   EditText edtFa1;
   @BindView(R.id.ll_fa_1)
   LinearLayout llFa1;
   @Override
   protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_first);
      Intent intent =getIntent();
      String data=intent.getStringExtra("extra_data");
      if (intent.getStringExtra("flag")!=null&& intent.getStringExtra("flag").equals("btn2result")){
         llFa1.setVisibility(View.VISIBLE);
      }else{
         llFa1.setVisibility(View.INVISIBLE);
      }
      tvFa1.setText(data);

   }

   @Override
   public void onBackPressed() {
      super.onBackPressed();
      Intent intent =new Intent();
      intent.putExtra("data_return",edtFa1.getText().toString());
      setResult(RESULT_OK,intent);
      finish();
   }

   @OnClick(R.id.btn_fa_1)
   public void btn_fa_1(){
      Intent intent =new Intent();
      intent.putExtra("data_return",edtFa1.getText().toString());
      setResult(RESULT_OK,intent);
      finish();
   }
}
